// 导入模块
import {createPinia} from 'pinia'
// 创建store对象
const pinia = createPinia()

export default pinia
import {defineStore} from 'pinia'
import indexApi, { type IndexData, type IndexDataList } from '@/api/index'
import type {FocusList,PolicyDescList,KingKongList,ItemList,
  IndexActivityModule,
  CategoryHotSellModule,
  CategoryList,
  
} from '@/api/index'

interface StateType {
  focusList:FocusList[],
  iconList:PolicyDescList[],
  kingKongLists:KingKongList[],
  bigPromo:ItemList[],
  indexActivity:IndexActivityModule[],
  categoryHot:CategoryHotSellModule,
  categoryList:CategoryList[],
  title:CategoryList[],
  category:CategoryList[],
  sceneLights:any[],
  sceneLight1:any[]
}

export const  useIndexStore = defineStore('userIndex',{
  state():StateType {
    return {
      focusList:[],
      iconList:[],
      kingKongLists:[],
      bigPromo:[],
      indexActivity:[],
      categoryHot:{
        title: '',
        categoryList: []
      },
      categoryList:[],
      title:[],
      category:[],
      sceneLights:[],
      sceneLight1:[]
    }
  },
  actions:{
    async getIndexData (){
      const result = await indexApi.getIndexData()
      this.focusList = result.data.focusList
      this.iconList = result.data.policyDescList
      this.kingKongLists = result.data.kingKongModule.kingKongList
      this.bigPromo = result.data.bigPromotionModule.floorList[0].cells[0].itemList
      this.indexActivity = result.data.indexActivityModule 
      this.categoryHot = result.data.categoryHotSellModule
      this.categoryList = result.data.categoryHotSellModule.categoryList
      this.title = this.categoryList.slice(0,2)
      this.category = this.categoryList.slice(2)
      this.sceneLights = result.data.sceneLightShoppingGuideModule
      
      this.sceneLights = this.sceneLights
      this.sceneLight1 = this.sceneLights
    }
  },
  getters:{}
})
